package com.huajx.tuopuda.client.udp.codec;

import com.huajx.tuopuda.client.udp.TuopudaUtil;

/**
 * 9.2.3.4读取运行状态信息[1081]
 * <p>
 * 如果是00000000或FFFFFFFF表明是最新的一条记录
 *
 * @author: lisa 叶新华
 * @create: 2019-09-28 20:38
 */
public class ReadRunStatusCodec extends AbstractCodec {
    private int index = 0; // 要读取的最新记录索引位

    public ReadRunStatusCodec(int sn) {
        setSn(sn);
    }

    public ReadRunStatusCodec(int sn, int index) {
        this(sn);
        this.index = index;
    }

    @Override
    public byte[] encode() {
        return encode(getSn(), 0x1081, bytes -> index == 0 ? 0 : TuopudaUtil.replaceBytes(bytes, index, 5, 4));
    }

    @Override
    public void decode(byte[] bytes) {

    }
}
